import request from '@/common/request.js'
import {LossRecordForm, RepairRequestForm} from "./type";




//查询新闻信息
const getNews = (id) => {
    const url = `8185/news?id=${id}`;
    return request.globalRequest(url, 'GET', null, 1)
};

//获取新闻信息列表
const getNewsList = () => {
    const url = '8185/news/list';
    return request.globalRequest(url, 'GET', null, 1)
};


//查询校园卡信息
const getCampusCardInfo = () => {
    const url = '8184/campusCard';
    return request.globalRequest(url, 'GET', null, 1)
};


//查询余额及交易记录
const getTransactionRecord = () => {
    const url = '8184/campusCard/trade';
    return request.globalRequest(url, 'GET', null, 1)
};


//校园卡挂失
const lossCard = (param) => {
    const url = '8184/campusCard/loss';
    return request.globalRequest(url, 'POST', param, 1)
};

//报修申请
const repairRequest = (param) => {
    const url = '8184/campusRepair/repair';
    return request.globalRequest(url, 'POST', param, 1)
};
//取消报修订单
const cancelRepair = (id) => {
    const url = `8184/campusRepair/cancel/${id}`
    return request.globalRequest(url, 'GET', {}, 1)
}

//报修详情
const repairDetail = (id) => {
    const url = `8184/campusRepair?id=${id}`
    return request.globalRequest(url, 'GET', {}, 1)
};


//我的报修列表
const myRepairDetail = () => {
    const url = '8184/campusRepair/myRepair';
    return request.globalRequest(url, 'GET', null, 1)
};
//学生获取课表
const getStudentCourseTable = (weekDay) => {
    const url = `8183/courseSchedule/get-table/${weekDay}`;
    return request.globalRequest(url, 'GET', {}, 1)
};
//删除排课
const deleteCourseSchedule = (scheduleId) => {
    const url = `8183/delete-schedule/${scheduleId}`;
    return request.globalRequest(url, 'DELETE', {}, 1)
};
//学生获取已选课程
const stuCourses = () => {
    const url = '8183/course/stu-courses';
    return request.globalRequest(url, 'GET', {}, 1)
};
//学生搜索课程
const searchCourses = (keyWords) => {
    const url = `8183/course/search-course/${keyWords}`;
    return request.globalRequest(url, 'GET', {}, 1)
};
//学生获取所有课程
const selectAllCourses = () => {
    const url = '8183/course/get-all-course';
    return request.globalRequest(url, 'GET', {}, 1)
};
//学生选课
const stuChooseCourse = (courseId) => {
    const url = `8183/courseSchedule/choose-course/${courseId}`;
    return request.globalRequest(url, 'GET', {}, 1)
};
//学生退课
const stuCancelCourse = (courseId) => {
    const url = `8183/courseSchedule/cancel-course/${courseId}`;
    return request.globalRequest(url, 'GET', {}, 1)
};
//编辑学生信息
const editStudentFun = (data) => {
    const url = '8181/student/editStudent';
    return request.globalRequest(url, 'POST', data, 1)
};
//完善学生信息
const addStudentFun = (data) => {
    const url = '8181/student/addStudent';
    return request.globalRequest(url, 'POST', data, 1)
};

//学生获取成绩单
const getStuGrades = () => {
    const url = '8185/academicGrade/stu-scores';
    return request.globalRequest(url, 'GET', null, 1)
};

//上传图片信息
const uploadImage = (fileData) => {
    const url = '8185/news/uploadImage'
    const file = new FormData();
    file.append('file', fileData); // 将文件添加到FormData对象中
    return request.globalRequest(url, 'POST', file, 1)
};

//电费充值
const InsertElectronicFeeInfoFun = (param) => {
    const url = '8184/campusFee/insertElectronicFee';
    return request.globalRequest(url, 'POST', param, 1)
};

//水费充值
const InsertWaterFeeInfoFun = (param) => {
    const url = '8184/campusFee/insertWaterFee';
    return request.globalRequest(url, 'POST', param, 1)
};

//费用统计
const getElectricityStatistics = (param) => {
    const url = '8184/campusFee/getStatistics';
    return request.globalRequest(url, 'GET', param, 1)
};
//学生获取所有消息
const stuGetMessages = () => {
    const url = '8182/message/stu-get-messages';
    return request.globalRequest(url, 'GET', {}, 1)
}
//学生删除消息
const stuDeleteMessages = (messageId) => {
    const url = `8182/message/stu-delete-messages/${messageId}`;
    return request.globalRequest(url, 'GET', {}, 1)
}
export default {
    getNews, getNewsList,
    getCampusCardInfo, getTransactionRecord, lossCard,
    repairRequest, repairDetail, myRepairDetail,
	getStudentCourseTable, deleteCourseSchedule, cancelRepair,
    stuCourses, searchCourses, selectAllCourses, stuChooseCourse, stuCancelCourse,
    editStudentFun,addStudentFun,
    getStuGrades,
    uploadImage,
    InsertElectronicFeeInfoFun, InsertWaterFeeInfoFun, getElectricityStatistics,
    stuGetMessages,stuDeleteMessages
}